package com.google.code.training_java_basic.oop;

import java.util.List;

public class Reports {

	public static void printNetworkElementData(List<NetworkElementConnector> connectors) {

		for (NetworkElementConnector connector : connectors) {
			System.out.printf("Connection Name: %s, Network Element Name: %s, Network Element IP: %s, " +
							"User name: %s, User password: %s\n",
					connector.getConnectionName(),
					connector.getNetworkElement().getNetworkElementName(),
					connector.getNetworkElement().getIp(),
					connector.getAccount().getUserName(),
					connector.getAccount().getPassword());
		}
	}
	
	public static void printGeneralAlarmInfo(List<Alarm> alarms) {
		
		System.out.printf("Minor(1): %d alarms\n", getNumberOfAlarmsBySeverity(1,alarms));
		System.out.printf("Major(2): %d alarms\n", getNumberOfAlarmsBySeverity(2,alarms));
		System.out.printf("Critical(3): %d alarms\n", getNumberOfAlarmsBySeverity(3,alarms));
		
	}
	
	public static void printAlarms(List<Alarm> alarms) {

		System.out.printf("Totally: %d alarms\n", alarms.size());
		for (Alarm alarm: alarms) {
			System.out.printf("Alarm Id: %d, Alarm number: %d, Alarm severity: %d, Alarm text: %s, Alarm time: %tc, Ceased time %tc \n",
							alarm.getAlarmId(),
							alarm.getAlarmNumber(),
							alarm.getSeverity(),
							alarm.getAlarmText(),
							alarm.getAlarmTime(),
							alarm.getClearTime());
		}
	}
	
	public static int getNumberOfAlarmsBySeverity(int severity, List<Alarm> alarms) {
		int result = 0;
		for (Alarm alarm: alarms) {
			if (alarm.getSeverity() == severity) {
				result++;
			}
		}

		return result;
	}
}


